package com.hbx.auth;

import com.hbx.model.User;

/*
 * @Author:hbx
 * 
 * */
public class AuthCacheService {
    private static ThreadLocal<User> userThreadLocal;
    private static ThreadLocal<Token> tokenThreadLocal;

    static {
        userThreadLocal = new ThreadLocal<User>();
        tokenThreadLocal = new ThreadLocal<Token>();
    }

    public static void setUserThreadLocal(User user){
        userThreadLocal.set(user);
    }

    public static void setTokenThreadLocal(Token token){
        tokenThreadLocal.set(token);
    }

    public static User getUser(){
        return userThreadLocal.get();
    }

    public static Token getToken(){
        return tokenThreadLocal.get();
    }

    public static void removeUser() {
        userThreadLocal.remove();
    }

    public static void removeToken() {
        tokenThreadLocal.remove();
    }
}
